package app;

import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import java.text.ParseException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.*;

import framework.DataBaseUtils;
import javax.swing.GroupLayout.Alignment;
import javax.swing.border.TitledBorder;
import javax.swing.text.MaskFormatter;

import org.testng.reporters.EmailableReporter;

public class MainGuiRegistrationForm extends JFrame implements
		PropertyChangeListener {

	private static final long serialVersionUID = 1L;
	protected static JFrame mainFrame;

	/**
	 * Creates new form ContactEditor
	 */
	public MainGuiRegistrationForm() {
		initComponents();
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {
		// test

		declareElements();

		setupElementBounds();

		setupLabels();

		setupButtons();

		drawRegisterResultFrame();

		setupTextFields();

		addElementsToOrgDataPanel();

		setupRadioCheckBoxes();

		addElementsToStendPanel();

		addElementsToUserDataPanel();

		addElementsToIntSettingsPanel();

		drawfstTabContainerPanel(stendPanel);

		pack();

	}// </editor-fold>

	protected void addElementsToIntSettingsPanel() {
		intSettingsPanel.setBorder(BorderFactory
				.createTitledBorder("Настройки интеграции"));
		intSettingsPanel.setLayout(null);
		intSettingsPanel.setVisible(false);

		intSettingsPanel.add(integrationUserLoginLabel);
		intSettingsPanel.add(integrationUserLoginTextField);
		intSettingsPanel.add(integrationUserPasswordLabel);
		intSettingsPanel.add(integrationUserPasswordTextField);

		intSettingsPanel.add(setIntPermissionsCheckBox);
	}

	protected void addElementsToUserDataPanel() {
		userDataPanel.setBorder(BorderFactory
				.createTitledBorder("Данные администратора организации "));
		userDataPanel.setLayout(null);
		userDataPanel.add(lastNameLabel);
		userDataPanel.add(firstNameLabel);
		userDataPanel.add(loginLabel);
		userDataPanel.add(userLoginTextField);
		userDataPanel.add(lastNameTextField);
		userDataPanel.add(middleNameTextField);
		userDataPanel.add(firstNameTextField);
		userDataPanel.add(middleNameLabel);
		userDataPanel.add(checkUserDataButton);
		userDataPanel.add(isLoginUniqueLabel);
		userDataPanel.add(setUserPermissionsCheckBox);
	}

	protected void addElementsToStendPanel() {
		stendPanel.setBorder(BorderFactory.createTitledBorder("Выбор стенда"));
		stendPanel.setLayout(null);
		stendPanel.add(stendKpakRadioButton);
		stendPanel.add(stendIntRadioButton);
		stendPanel.add(stendTpakRadioButton);

		chooseStendButtonGroup.add(stendKpakRadioButton);
		chooseStendButtonGroup.add(stendIntRadioButton);
		chooseStendButtonGroup.add(stendTpakRadioButton);
	}

	protected void setupRadioCheckBoxes() {
		createIntUserCheckBox.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				int stateValue = e.getStateChange();
				if (stateValue == 1) {
					intSettingsPanel.setVisible(true);
					setIntSelected(true);
				} else {
					intSettingsPanel.setVisible(false);
					setIntSelected(true);
				}
			}
		});

		stendIntRadioButton.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				int stateVal = e.getStateChange();
				if (stateVal == 1) {
					setSelectedStend(4);
				}
			}
		});

		stendTpakRadioButton.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				int stateVal = e.getStateChange();
				if (stateVal == 1) {
					setSelectedStend(2);
				}
			}
		});

		stendTpakRadioButton.setSelected(true);
		setSelectedStend(2);

		stendKpakRadioButton.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				int stateVal = e.getStateChange();
				if (stateVal == 1) {
					setSelectedStend(1);
				}
			}
		});

		checkUserDataButton.setText("Проверить уникальность логина");
		checkUserDataButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				checkUserDataButtonActionPerformed(evt);
			}
		});

		setUserPermissionsCheckBox.setSelected(true);
		setIsSetUserPermissions(1);
		setUserPermissionsCheckBox.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				setIsSetUserPermissions(e.getStateChange());
			}
		});

		setIntPermissionsCheckBox.setSelected(true);
		setIsSetIntPermissions(1);
		setIntPermissionsCheckBox.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				setIsSetIntPermissions(e.getStateChange());
			}
		});

	}

	protected void addElementsToOrgDataPanel() {
		orgDataPanel.setLayout(null);
		orgDataPanel.add(fullNameLabel);
		orgDataPanel.add(ogrnLabel);
		orgDataPanel.add(innLabel);
		orgDataPanel.add(kppLabel);
		orgDataPanel.add(phoneLabel);
		orgDataPanel.add(fullNameTextField);
		orgDataPanel.add(ogrnTextField);
		orgDataPanel.add(emailLabel);
		orgDataPanel.add(kppTextField);
		orgDataPanel.add(innTextField);
		orgDataPanel.add(phoneTextField);
		orgDataPanel.add(checkOrgDataButton);
		orgDataPanel.add(isKppUniqueLabel);
		orgDataPanel.add(isOgrnUniqueLabel);
		orgDataPanel.add(emailTextField);
		orgDataPanel.add(isInnUniqueLabel);
		orgDataPanel.add(createIntUserCheckBox);
	}

	protected void drawfstTabContainerPanel(JPanel stendPanel) {

		JTabbedPane fstTabbedPane = new JTabbedPane(JTabbedPane.TOP);
		fstTabbedPane.setBorder(new TitledBorder(null, "xccxc",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));
		fstTabbedPane.setBounds(10, 6, 710, 750);
		getContentPane().add(fstTabbedPane);
		fstTabContainerPanel.setBorder(null);
		fstTabbedPane.addTab("Основные параметры регистрации", null,
				fstTabContainerPanel, null);
		fstTabbedPane.setBorder(null);

		orgDataPanel.setBorder(BorderFactory
				.createTitledBorder("Данные организации "));
		orgDataPanel.setPreferredSize(new java.awt.Dimension(700, 180));

		GroupLayout gl_fstTabContainerPanel = new GroupLayout(
				fstTabContainerPanel);
		gl_fstTabContainerPanel
				.setHorizontalGroup(gl_fstTabContainerPanel
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_fstTabContainerPanel
										.createSequentialGroup()
										.addGap(6)
										.addGroup(
												gl_fstTabContainerPanel
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																stendPanel,
																GroupLayout.PREFERRED_SIZE,
																700,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(
																orgDataPanel,
																GroupLayout.PREFERRED_SIZE,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.PREFERRED_SIZE)))
						.addGroup(
								gl_fstTabContainerPanel
										.createSequentialGroup()
										.addGap(6)
										.addComponent(userDataPanel,
												GroupLayout.PREFERRED_SIZE,
												700, GroupLayout.PREFERRED_SIZE))
						.addGroup(
								gl_fstTabContainerPanel
										.createSequentialGroup()
										.addGap(6)
										.addComponent(intSettingsPanel,
												GroupLayout.PREFERRED_SIZE,
												700, GroupLayout.PREFERRED_SIZE))
						.addGroup(
								gl_fstTabContainerPanel
										.createSequentialGroup()
										.addGap(278)
										.addComponent(registerButton)
										.addGap(41)
										.addComponent(cancelButton)
										.addGap(33)
										.addComponent(clearFormButon,
												GroupLayout.PREFERRED_SIZE,
												137, GroupLayout.PREFERRED_SIZE)));
		gl_fstTabContainerPanel
				.setVerticalGroup(gl_fstTabContainerPanel
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_fstTabContainerPanel
										.createSequentialGroup()
										.addGap(6)
										.addGroup(
												gl_fstTabContainerPanel
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																stendPanel,
																GroupLayout.PREFERRED_SIZE,
																58,
																GroupLayout.PREFERRED_SIZE)
														.addGroup(
																gl_fstTabContainerPanel
																		.createSequentialGroup()
																		.addGap(56)
																		.addComponent(
																				orgDataPanel,
																				GroupLayout.PREFERRED_SIZE,
																				261,
																				GroupLayout.PREFERRED_SIZE)))
										.addComponent(userDataPanel,
												GroupLayout.PREFERRED_SIZE,
												181, GroupLayout.PREFERRED_SIZE)
										.addComponent(intSettingsPanel,
												GroupLayout.PREFERRED_SIZE,
												115, GroupLayout.PREFERRED_SIZE)
										.addGap(14)
										.addGroup(
												gl_fstTabContainerPanel
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																registerButton,
																GroupLayout.PREFERRED_SIZE,
																30,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(
																cancelButton,
																GroupLayout.PREFERRED_SIZE,
																30,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(
																clearFormButon,
																GroupLayout.PREFERRED_SIZE,
																30,
																GroupLayout.PREFERRED_SIZE))));
		fstTabContainerPanel.setLayout(gl_fstTabContainerPanel);
	}

	protected void setupTextFields() {
		fullNameTextField = new JFormattedTextField();
		setVerifiedInputComponent(fullNameTextField, "My_AUTO test 01",
				"fullNameTextField", 170, 28, 218, 30, verifier, "Полное наименование должно содержать не менее 3 символов");

		emailTextField = new javax.swing.JTextField();
		setVerifiedInputComponent(emailTextField, "pgz223fz@yandex.ru",
				"emailTextField", 464, 28, 218, 30, verifier, "Введите действительный имейл адрес. Например, test@test.com");

		MaskFormatter phoneMask = getMaskFormatter("*-***-*******",
				"0123456789-");
		phoneTextField = new JFormattedTextField(phoneMask);
		setVerifiedInputComponent(phoneTextField, "8-495-9938028",
				"phoneTextField", 170, 176, 218, 30, verifier, "Номер телефона должен соответствовать маске #-###-#######, например 8-495-9938028");

		MaskFormatter ogrnMask = getMaskFormatter("*************", "0123456789");
		ogrnTextField = new JFormattedTextField(ogrnMask);
		setVerifiedInputComponent(ogrnTextField, "9999999999993",
				"ogrnTextField", 170, 64, 218, 30, verifier, "ОГРН должен содержать 13 цифр");

		MaskFormatter innMask = getMaskFormatter("**********", "0123456789");
		innTextField = new JFormattedTextField(innMask);
		setVerifiedInputComponent(innTextField, "4444444493",
				"innTextField", 170, 139, 218, 30, verifier, "ИНН должен содержать 10 цифр");

		MaskFormatter kppMask = getMaskFormatter("*********", "0123456789");
		kppTextField = new JFormattedTextField(kppMask);
		setVerifiedInputComponent(kppTextField, "444444493", "kppTextField",
				170, 103, 218, 30, verifier, "КПП должен содержать 9 цифр");

		userLoginTextField = new JFormattedTextField();
		setVerifiedInputComponent(userLoginTextField, "223-223-223 55",
				"loginTextField", 168, 28, 218, 30, verifier, "Логин должен содержать минимум 3 символа, например 223-15");
		userLoginTextField.setPreferredSize(new java.awt.Dimension(84, 20));

		firstNameTextField = new JFormattedTextField();
		setVerifiedInputComponent(firstNameTextField, "MY_Имя-Тест",
				"firstNameTextField", 168, 100, 218, 30, verifier, "Имя должно содержать минимум 3 символа");
		firstNameTextField.setPreferredSize(new java.awt.Dimension(84, 20));

		lastNameTextField = new JFormattedTextField();
		setVerifiedInputComponent(lastNameTextField, "MY_Фамилия-Тест",
				"lastNameTextField", 168, 64, 218, 30, verifier, "Фамилия должна содержать минимум 3 символа");
		lastNameTextField.setPreferredSize(new java.awt.Dimension(84, 20));

		middleNameTextField = new JFormattedTextField();
		setVerifiedInputComponent(middleNameTextField, "MY_Отчество-Тест",
				"middleNameTextField", 168, 136, 218, 30, verifier, "Отчество должно содержать минимум 3 символа");

		setVerifiedInputComponent(integrationUserLoginTextField, "223-223 55",
				"integrationUserLoginTextField", 170, 32, 218, 30, verifier, "Логин должен содержать минимум 3 символа");
		integrationUserLoginTextField.setPreferredSize(new Dimension(84, 20));

		setVerifiedInputComponent(integrationUserPasswordTextField,
				"123asdASD", "integrationUserPasswordTextField", 170, 68, 218,
				30, verifier, "Пароль должен содержать минимум 3 цифры, 3 латинских строчных буквы и 3 латинских прописных, быть не более 20 символов");
		integrationUserPasswordTextField
				.setPreferredSize(new Dimension(84, 20));

	}

	protected void setupElementBounds() {
		fullNameLabel.setBounds(20, 35, 132, 16);
		emailLabel.setBounds(426, 35, 32, 16);
		phoneLabel.setBounds(101, 183, 51, 16);
		ogrnLabel.setBounds(119, 71, 33, 16);
		innLabel.setBounds(125, 146, 27, 16);
		kppLabel.setBounds(127, 110, 25, 16);
		checkOrgDataButton.setBounds(464, 176, 218, 30);
		isOgrnUniqueLabel.setBounds(464, 73, 218, 14);
		isKppUniqueLabel.setBounds(464, 112, 218, 14);
		isInnUniqueLabel.setBounds(464, 148, 218, 14);
		createIntUserCheckBox.setBounds(170, 221, 263, 18);
		stendIntRadioButton.setBounds(388, 26, 125, 18);
		stendKpakRadioButton.setBounds(21, 26, 125, 18);
		stendTpakRadioButton.setBounds(198, 26, 125, 18);

		isLoginUniqueLabel.setBounds(463, 37, 218, 14);
		loginLabel.setBounds(117, 35, 33, 16);
		firstNameLabel.setBounds(121, 107, 29, 16);

		lastNameLabel.setBounds(97, 71, 53, 16);

		middleNameLabel.setBounds(97, 143, 59, 16);

		checkUserDataButton.setBounds(463, 64, 218, 30);
		setUserPermissionsCheckBox.setBounds(463, 106, 218, 18);

		integrationUserLoginLabel.setBounds(50, 32, 108, 16);
		integrationUserPasswordLabel.setBounds(37, 68, 121, 16);

		setIntPermissionsCheckBox.setBounds(462, 38, 218, 18);

	}

	protected void setupButtons() {

		registerButton.setText("Зарегистрировать");

		cancelButton.setText("Отмена");

		clearFormButon.setText("Очистить форму");
		okSuccessButton.setText("ОК");

		okSuccessButton.setText("Ок");
		okSuccessButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				okSuccessButtonActionPerformed(evt);
			}
		});

		clearFormButon.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				clearFormButonActionPerformed(evt);
			}
		});
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				cancelButtonActionPerformed(evt);
			}
		});
		registerButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				registerButtonActionPerformed(evt);
			}
		});

		checkOrgDataButton.setText("Проверить уникальность ОГРН+ИНН+КПП");
		checkOrgDataButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				checkOrgDataButtonActionPerformed(evt);
			}
		});
	}

	protected void setupLabels() {
		infoResultLabel.setText("Организация была зарегистрирована "
				+ "со следующими параметрами:");
		infoResultFullNameLabel.setText("Полное наименование:");
		infoResultLoginLabel.setText("Логин:");
		infoResultPasswordLabel.setText("Пароль:");
		registrationSuccessLabel.setText("Регистрация успешно завершена!");
		fullNameLabel.setText("Полное наименование");
		emailLabel.setText("Email");
		phoneLabel.setText("Телефон");
		ogrnLabel.setText("ОГРН");

		registrationSuccessLabel.setFont(new java.awt.Font("SansSerif", 1, 14)); // NOI18N

		registrationSuccessLabel.setForeground(OK_LABEL_COLOR);

		isOgrnUniqueLabel.setFont(NORMAL_FONT); // NOI18N
		isOgrnUniqueLabel.setForeground(BLACK_FOREGROUNG);
		isOgrnUniqueLabel.setText("isOrgnUniqueLabel TEXT");
		isOgrnUniqueLabel.setVisible(false);
		isOgrnUniqueLabel.setName("ОГРН");

		isKppUniqueLabel.setFont(NORMAL_FONT); // NOI18N
		isKppUniqueLabel.setForeground(BLACK_FOREGROUNG);
		isKppUniqueLabel.setText("isKppUniqueLabel TEXT");
		isKppUniqueLabel.setVisible(false);
		isKppUniqueLabel.setName("КПП");

		isInnUniqueLabel.setFont(NORMAL_FONT); // NOI18N
		isInnUniqueLabel.setForeground(BLACK_FOREGROUNG);
		isInnUniqueLabel.setText("isInnUniqueLabel TEXT");
		isInnUniqueLabel.setVisible(false);
		isInnUniqueLabel.setName("ИНН");

		innLabel.setText("ИНН");
		kppLabel.setText("КПП");

		loginLabel.setText("Логин");

		firstNameLabel.setText("Имя");
		firstNameLabel.setHorizontalTextPosition(SwingConstants.RIGHT);
		firstNameLabel.setInheritsPopupMenu(false);

		lastNameLabel.setText("Фамилия");

		middleNameLabel.setLabelFor(middleNameTextField);
		middleNameLabel.setText("Отчество");
		middleNameLabel.setHorizontalTextPosition(SwingConstants.RIGHT);

		isLoginUniqueLabel.setFont(NORMAL_FONT); // NOI18N
		isLoginUniqueLabel.setForeground(BLACK_FOREGROUNG);
		isLoginUniqueLabel.setText("isUserUniqueLabel TEXT");
		isLoginUniqueLabel.setVisible(false);
		isLoginUniqueLabel.setName("Логин");

		integrationUserLoginLabel.setText("Логин интеграции");
		integrationUserPasswordLabel.setText("Пароль интеграции");

		infoResultLabel
				.setText("Организация была зарегистрирована со следующими параметрами:");

		infoResultFullNameLabel.setText("Полное наименование:");

		infoResultLoginLabel.setText("Логин:");

		infoResultPasswordLabel.setText("Пароль:");

	}

	protected void declareElements() {
		registerResultFrame = new javax.swing.JFrame();
		registerResultPanel = new javax.swing.JPanel();
		registrationSuccessLabel = new javax.swing.JLabel();
		okSuccessButton = new javax.swing.JButton();
		infoResultLabel = new javax.swing.JLabel();
		infoResultFullNameLabel = new javax.swing.JLabel();
		infoResultLoginLabel = new javax.swing.JLabel();
		infoResultPasswordLabel = new javax.swing.JLabel();
		fstTabContainerPanel = new JPanel();
		orgDataPanel = new javax.swing.JPanel();
		stendPanel = new javax.swing.JPanel();
		fullNameLabel = new javax.swing.JLabel();
		emailLabel = new javax.swing.JLabel();
		phoneLabel = new javax.swing.JLabel();
		ogrnLabel = new javax.swing.JLabel();
		innLabel = new javax.swing.JLabel();
		kppLabel = new javax.swing.JLabel();
		checkOrgDataButton = new javax.swing.JButton();
		registerButton = new javax.swing.JButton();
		cancelButton = new javax.swing.JButton();
		clearFormButon = new javax.swing.JButton();
		isOgrnUniqueLabel = new javax.swing.JLabel();
		isKppUniqueLabel = new javax.swing.JLabel();
		isInnUniqueLabel = new javax.swing.JLabel();

		userDataPanel = new javax.swing.JPanel();
		loginLabel = new javax.swing.JLabel();
		firstNameLabel = new javax.swing.JLabel();

		lastNameLabel = new javax.swing.JLabel();

		middleNameLabel = new javax.swing.JLabel();

		checkUserDataButton = new javax.swing.JButton();
		isLoginUniqueLabel = new javax.swing.JLabel();

		createIntUserCheckBox = new JCheckBox("Создать пользователя интеграции");
		stendKpakRadioButton = new JRadioButton("КПАК (fz01.lanit.ru)");
		stendIntRadioButton = new JRadioButton("ИНТ (fz04.lanit.ru)");
		stendTpakRadioButton = new JRadioButton("ТПАК (fz02.lanit.ru)");

		setUserPermissionsCheckBox = new JCheckBox(
				"Проставить права пользователю");

		intSettingsPanel = new JPanel();
		integrationUserLoginLabel = new JLabel();
		integrationUserPasswordLabel = new JLabel();
		integrationUserLoginTextField = new JFormattedTextField();
		integrationUserPasswordTextField = new JFormattedTextField();

		setIntPermissionsCheckBox = new JCheckBox("Проставить права интеграции");

	}

	protected void drawRegisterResultFrame() {

		registerResultFrame
				.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		registerResultFrame.setCursor(new java.awt.Cursor(
				java.awt.Cursor.DEFAULT_CURSOR));
		registerResultFrame.setForeground(WHITE_FOREGROUND);
		registerResultFrame.setMinimumSize(new java.awt.Dimension(450, 250));
		registerResultFrame.setLocationRelativeTo(getParent());
		registerResultFrame.setTitle("Результат регистрации");

		registerResultPanel.setMinimumSize(new java.awt.Dimension(200, 300));

		org.jdesktop.layout.GroupLayout registerResultPanelLayout = new org.jdesktop.layout.GroupLayout(
				registerResultPanel);
		registerResultPanel.setLayout(registerResultPanelLayout);
		registerResultPanelLayout
				.setHorizontalGroup(registerResultPanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(registerResultPanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.add(registerResultPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.LEADING)
										.add(org.jdesktop.layout.GroupLayout.TRAILING,
												registerResultPanelLayout
														.createSequentialGroup()
														.add(registrationSuccessLabel,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																270,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(52, 52, 52))
										.add(registerResultPanelLayout
												.createSequentialGroup()
												.add(registerResultPanelLayout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.LEADING)
														.add(infoResultLabel)
														.add(registerResultPanelLayout
																.createSequentialGroup()
																.add(29, 29, 29)
																.add(registerResultPanelLayout
																		.createParallelGroup(
																				org.jdesktop.layout.GroupLayout.LEADING)
																		.add(infoResultFullNameLabel)
																		.add(org.jdesktop.layout.GroupLayout.LEADING,
																				infoResultLoginLabel)
																		.add(org.jdesktop.layout.GroupLayout.LEADING,
																				infoResultPasswordLabel)))
														.add(org.jdesktop.layout.GroupLayout.TRAILING,
																registerResultPanelLayout
																		.createSequentialGroup()
																		.add(okSuccessButton,
																				org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																				83,
																				org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
																		.add(126,
																				126,
																				126)))
												.addContainerGap()))));
		registerResultPanelLayout.setVerticalGroup(registerResultPanelLayout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(registerResultPanelLayout
						.createSequentialGroup()
						.addContainerGap()
						.add(registrationSuccessLabel)
						.add(11, 11, 11)
						.add(infoResultLabel)
						.add(18, 18, 18)
						.add(infoResultFullNameLabel,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)
						.addPreferredGap(
								org.jdesktop.layout.LayoutStyle.RELATED)
						.add(infoResultLoginLabel,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)
						.addPreferredGap(
								org.jdesktop.layout.LayoutStyle.RELATED)
						.add(infoResultPasswordLabel,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)
						.addPreferredGap(
								org.jdesktop.layout.LayoutStyle.RELATED,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE).add(okSuccessButton)
						.addContainerGap()));

		org.jdesktop.layout.GroupLayout registerResultFrameLayout = new org.jdesktop.layout.GroupLayout(
				registerResultFrame.getContentPane());
		registerResultFrame.getContentPane().setLayout(
				registerResultFrameLayout);
		registerResultFrameLayout.setHorizontalGroup(registerResultFrameLayout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(registerResultFrameLayout
						.createSequentialGroup()
						.addContainerGap()
						.add(registerResultPanel,
								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE).addContainerGap()));
		registerResultFrameLayout.setVerticalGroup(registerResultFrameLayout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(registerResultFrameLayout
						.createSequentialGroup()
						.addContainerGap()
						.add(registerResultPanel,
								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
								170, Short.MAX_VALUE)));

		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		setTitle("Форма ввода данных регистрируемой организации");
		setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
		setMaximumSize(new Dimension(710, 850));
		setPreferredSize(new Dimension(750, 750));
		getContentPane().setLayout(null);
	}

	protected MaskFormatter getMaskFormatter(String mask, String validChars) {
		MaskFormatter newMask = null;
		try {
			newMask = new MaskFormatter(mask);

		} catch (ParseException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		newMask.setValidCharacters(validChars);
		return newMask;
	}

	protected void setVerifiedInputComponent(JComponent input, String setText,
			String setName, int xBound, int yBound, int boundWidth,
			int boundHeight, MyVerifier verifier, String tolltip) {
		((JTextField) input).setText(setText);
		input.setBounds(xBound, yBound, boundWidth, boundHeight);
		input.setName(setName);
		input.setInputVerifier(verifier);
		((JTextField) input).addActionListener(verifier);
		input.setToolTipText(tolltip);
	}

	class MyVerifier extends InputVerifier implements ActionListener {

		public boolean shouldYieldFocus(JComponent input) {
			boolean inputOK = verify(input);

			if (inputOK) {
				input.setForeground(BLACK_FOREGROUNG);
				input.setFont(NORMAL_FONT);
				return true;
			}

			input.setForeground(ERR_LABEL_COLOR);
			input.setFont(WARNING_FONT);
			// Pop up the message dialog.
			/*
			 * message += ".\nPlease try again.";
			 * JOptionPane.showMessageDialog(null, //no owner frame message,
			 * //text to display "Invalid Value", //title
			 * JOptionPane.WARNING_MESSAGE);
			 */

			// Reinstall the input verifier.
			input.setInputVerifier(this);

			// Beep and then tell whoever called us that we don't
			// want to yield focus.
			Toolkit.getDefaultToolkit().beep();
			return false;
		}

		// This method checks input, but should cause no side effects.
		public boolean verify(JComponent input) {
			return validateField(input);
		}

		protected boolean validateField(JComponent input) {
			System.out.println("input = " + input);
			System.out.println("input.getName(); " + input.getName());

			if (input.getName().equals("ogrnTextField")) {

				return validateOgrnField();
			} else if (input.getName().equals("innTextField")) {

				return validateInnField();
			} else if (input.getName().equals("kppTextField")) {

				return validateKppField();
			} else if (input.getName().equals(fullNameTextField.getName())||
					input.getName().equals(userLoginTextField.getName())||
					input.getName().equals(firstNameTextField.getName())||
					input.getName().equals(middleNameTextField.getName())||
					input.getName().equals(lastNameTextField.getName())||
					input.getName().equals(integrationUserLoginTextField.getName())) {

				return validateRequiredTextField((JTextField) input);
			} else if (input.getName().equals("phoneTextField") ) {

				return validatePhoneField();
			} else if (input.getName().equals(emailTextField.getName())||
					input.getName().equals(integrationUserPasswordTextField.getName())) {

				return validateEmailField((JTextField) input);
			} else
				return true; // shouldn't happen
		}

		private boolean validateOgrnField() {
			String str = null;
			str = ogrnTextField.getText().trim();
			System.out.println("ogrnTextField.getText().trim()= " + str);
			System.out.println("str.length = " + str.length());
			if (str.length() != 13) {
				return false;
			} else
				return true;
		}

		private boolean validateInnField() {
			String str = null;
			str = innTextField.getText().trim();
			if (str.length() != 10) {
				return false;
			} else
				return true;
		}

		private boolean validateKppField() {
			String str = null;
			str = kppTextField.getText().trim();
			if (str.length() != 9) {
				return false;
			} else
				return true;
		}

		private boolean validateRequiredTextField(JTextField input) {
			String str = null;
			str = input.getText();
			if (str.length() < 3) {
				return false;
			} else
				return true;
		}

		private boolean validatePhoneField() {
			String str = null;
			str = phoneTextField.getText().trim();
			if (str.length() != 13) {
				return false;
			} else
				return true;
		}

		private boolean validateEmailField(JTextField input) {
			String field = input.getName();
			if (field.equals(emailTextField.getName()))
				pattern = Pattern.compile(EMAIL_PATTERN);
			else if (field.equals(integrationUserPasswordTextField.getName()))
				pattern = Pattern.compile(INT_PASSWORD_PATTERN);
			String str = null;
			str = input.getText().trim();
			matcher = pattern.matcher(str);
			return matcher.matches();
		}

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO
			JFormattedTextField source = (JFormattedTextField) e.getSource();
			// JTextField source = (JTextField)e.getSource();
			shouldYieldFocus(source); // ignore return value
			source.selectAll();

		}

	}

	protected void okSuccessButtonActionPerformed(ActionEvent evt) {

		JButton b = (JButton) evt.getSource();
		JFrame f = (JFrame) b.getParent().getParent().getParent().getParent()
				.getParent();
		f.dispose();

	}

	private void checkOrgDataButtonActionPerformed(ActionEvent evt) {
		initializeInputData();

		db.checkOrganizationIsUnique(orgFullName, orgOgrn, orgKpp, orgInn);
		displayCheckResults(db.OGRN_CHECK_RESULT, isOgrnUniqueLabel);
		displayCheckResults(db.INN_CHECK_RESULT, isInnUniqueLabel);
		displayCheckResults(db.KPP_CHECK_RESULT, isKppUniqueLabel);

	}

	private void checkUserDataButtonActionPerformed(ActionEvent evt) {
		initializeInputData();
		db.checkUserIsUnique(userLogin, db.LOGIN_CHECK_RESULT);
		displayCheckResults(db.LOGIN_CHECK_RESULT, isLoginUniqueLabel);
	}

	private void registerButtonActionPerformed(ActionEvent evt) {

		String ogrnResult = null, kppResult = null, innResult = null, loginResult = null, intLoginResult = null;
		initializeInputData();

		db.checkOrganizationIsUnique(orgFullName, orgOgrn, orgKpp, orgInn);
		ogrnResult = db.getCheckResults(db.OGRN_CHECK_RESULT);
		kppResult = db.getCheckResults(db.KPP_CHECK_RESULT);
		innResult = db.getCheckResults(db.INN_CHECK_RESULT);

		db.checkUserIsUnique(userLogin, db.LOGIN_CHECK_RESULT);
		loginResult = db.getCheckResults(db.LOGIN_CHECK_RESULT);

		if (isIntSelected()) {
			userIntLogin = integrationUserLoginTextField.getText();
			userIntPassword = integrationUserPasswordTextField.getText();
			db.checkUserIsUnique(userIntLogin, db.INT_LOGIN_CHECK_RESULT);
			intLoginResult = db.getCheckResults(db.INT_LOGIN_CHECK_RESULT);
		}

		/*
		 * System.out.println("ogrnResult= " + ogrnResult);
		 * System.out.println("kppResult= " + kppResult);
		 * System.out.println("innResult= " + innResult);
		 * System.out.println("loginResult= " + loginResult);
		 * System.out.println("intLoginResult= " + intLoginResult);
		 */

		
		if (ogrnResult != db.CHECK_RESULT_OK || kppResult != db.CHECK_RESULT_OK
				|| innResult != db.CHECK_RESULT_OK
				|| loginResult != db.CHECK_RESULT_OK
				|| (isIntSelected() && intLoginResult != db.CHECK_RESULT_OK)) {
//if (false){
			JFrame frame = drawNewFrame("Промежуточный контроль");
			centerFrame(frame, true);

			JPanel p = new JPanel();
			String introText = "<html>Некоторые введенные реквизиты уже испльзуются в системе. "
					+ "<br>Пожалуйста, укажите уникальные реквизиты: <br><br></html>";
			Dimension d = new Dimension(400, 250);
			drawIntermediateWindow(frame, p, introText, false, d);

			checkResultsAddLabel(ogrnResult, "ОГРН", orgOgrn, p);
			checkResultsAddLabel(kppResult, "КПП", orgKpp, p);
			checkResultsAddLabel(innResult, "ИНН", orgInn, p);
			checkResultsAddLabel(loginResult, "Логин", userLogin, p);
			if (isIntSelected() && intLoginResult != db.CHECK_RESULT_OK) {
				checkResultsAddLabel(intLoginResult, "Логин интеграции",
						userIntLogin, p);
			}

		}

		else {
			
			  // инициализирует данные из формы
			  
			 // вставляет адрес организации 
			db.insertOrgAddress(); 
			// получаем ИД вставленного адреса по зип_коду 
			orgAddressId = DataBaseUtils.getAddressId(DataBaseUtils.ZIP_CODE_REPLACEMENT); 
			// вставляет   организацию 
			db.insertOrganization(orgFullName, orgOgrn, orgInn,
			  orgKpp, orgAddressId, orgPhone, orgWebsite, orgEmail,
			  isIntSelected); 
			// вставляет пользователя
			  db.insertUser(userLogin, userFirstName, userMiddleName,
			  userLastName, orgFullName, orgOgrn);
			  
			  if (getIsSetUserPermissions() == 1) { orgId =
			  db.getCustomerId(orgFullName, orgOgrn); userId =
			  db.getUserId(userLogin, orgOgrn, 0);
			  db.insertUserPermissions(userId, orgId); }
			  
			  if (isIntSelected()) { userIntLogin =
			  integrationUserLoginTextField.getText(); userIntPassword =
			  integrationUserPasswordTextField.getText();
			  db.insertFakeUser(userIntLogin, userIntPassword, orgFullName,
			  orgOgrn); boolean b; if (getIsSetIntPermissions() == 1) b = true;
			  else b = false;
			  
			  db.insertIntSettings(orgFullName, orgOgrn, b);
			  db.insertIntUser(userIntLogin, userIntPassword, orgFullName,
			  orgOgrn); }
			 
			displayResultWindow();

		}
	}

	protected void drawIntermediateWindow(JFrame frame, JPanel p,
			String introText, boolean isOkFont, Dimension d) {
		p.add(Box.createRigidArea(new Dimension(5, 5)));
		frame.setMinimumSize(d);
		frame.setPreferredSize(d);
		frame.setLocationRelativeTo(getParent());
		p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
		JLabel l = new JLabel(introText);
		if (isOkFont) {
			l.setForeground(OK_LABEL_COLOR);
		} else {
			l.setForeground(ERR_LABEL_COLOR);
		}
		l.setFont(NORMAL_FONT);
		l.setAlignmentX(LEFT_ALIGNMENT);
		p.add(l);

		JButton button = new JButton("Ok");
		button.setAlignmentY(Component.BOTTOM_ALIGNMENT);
		button.setAlignmentX(Component.CENTER_ALIGNMENT);
		button.setPreferredSize(new Dimension(83, 30));
		button.setMinimumSize(new Dimension(83, 30));
		button.setMaximumSize(new Dimension(83, 30));
		button.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				okSuccessButtonActionPerformed(evt);
			}
		});

		Box box = Box.createVerticalBox();
		box.setPreferredSize(new Dimension(200, 40));
		box.setMinimumSize(new Dimension(200, 40));
		box.add(button);

		frame.getContentPane().add(p, BorderLayout.CENTER);
		frame.getContentPane().add(box, BorderLayout.PAGE_END);
	}

	private void initializeInputData() {
		orgFullName = fullNameTextField.getText();
		orgEmail = emailTextField.getText();
		orgKpp = kppTextField.getText();
		orgOgrn = ogrnTextField.getText();
		orgInn = innTextField.getText();
		orgPhone = phoneTextField.getText();
		orgWebsite = "www.test.com";
		userLogin = userLoginTextField.getText();
		userFirstName = firstNameTextField.getText();
		userLastName = lastNameTextField.getText();
		userMiddleName = middleNameTextField.getText();
	}

	private void displayCheckResults(String resultKey, JLabel label) {
		String checkResult = db.getCheckResults(resultKey);
		if (checkResult.equals(db.CHECK_RESULT_OK)) {
			label.setVisible(true);
			label.setForeground(OK_LABEL_COLOR);
			label.setText(checkResult);
		} else {
			label.setVisible(true);
			label.setForeground(ERR_LABEL_COLOR);
			label.setText("Реквизит " + label.getName() + " занят :(");
		}

	}

	/*
	 * private String getLabelResultName(JLabel label) { String str =
	 * label.getName(); String result = ""; switch (str) { case
	 * "isOgrnUniqueLabel": result = "ОГРН"; break; case "isKppUniqueLabel":
	 * result = "КПП"; break; case "isInnUniqueLabel": result = "ИНН"; break;
	 * case "isUserUniqueLabel": result = "ИНН"; break;
	 * 
	 * default: break; } return result;
	 * 
	 * }
	 */

	private void displayResultWindow() {
		JFrame frame = drawNewFrame("Регистрация успешно завершена!");
		centerFrame(frame, true);

		JPanel p = new JPanel();
		String introText = "<html>Организация была зарегистрирована со следующими параметрами:<br><<br></html>";
		Dimension d = new Dimension(400, 250);
		drawIntermediateWindow(frame, p, introText, true, d);
		addResultLabelText("Название организации ", orgFullName, p);
		addResultLabelText("Логин", userLogin, p);
		addResultLabelText("Пароль", userPassword, p);
		if (isIntSelected()) {
			addResultLabelText("Логин интеграции", userIntLogin, p);
			addResultLabelText("Пароль интеграции", userIntPassword, p);
		}

		// TODO clean unused swing
		registerResultFrame.setVisible(false);
		infoResultFullNameLabel.setText("Полное наименование: " + orgFullName);
		infoResultLoginLabel.setText("Логин: " + userLogin);
		infoResultPasswordLabel.setText("Пароль: " + userPassword);
	}

	private void cancelButtonActionPerformed(ActionEvent evt) {
		dispose();
	}

	private void clearFormButonActionPerformed(ActionEvent evt) {
		clearTextFields(this);
		// String s = db.getUserId("223-223 04", "9999999999925", 1) ;
		// String o = db.getCustomerId("Тестовая организация 25",
		// "9999999999925");
		/*
		 * System.out.println("db.getCheckResults(db.OGRN_CHECK_RESULT)= " +
		 * db.getCheckResults(db.OGRN_CHECK_RESULT));
		 */// initializeInputData();
			// db.insertFakeUser("222-333", "222-333", orgFullName, orgOgrn);
			// db.insertIntSettings(orgFullName, orgOgrn, true);
			// db.insertIntUser("222-333", "222-333", orgFullName, orgOgrn);

	}

	void clearTextFields(Container container) {
		for (Component c : container.getComponents()) {
			if (c instanceof JTextField) {
				((JTextField) c).setText("");
			} else if (c instanceof Container) {
				clearTextFields((Container) c);
			}
		}
	}

	public void checkResultsAddLabel(String fieldValue, String fieldName,
			String inputValue, JPanel panel) {
		if (fieldValue != db.CHECK_RESULT_OK) {
			addIntermediateLabelText(fieldName, inputValue, panel);
		}
	}

	public void addIntermediateLabelText(String fieldName, String inputValue,
			JPanel panel) {
		JLabel label = new JLabel();
		label.setText("<html>Реквизит <strong>" + fieldName + "</strong> : "
				+ inputValue + " - уже занят!</html>");
		label.setFont(NORMAL_FONT);
		panel.add(label);

	}

	public void addResultLabelText(String fieldName, String inputValue,
			JPanel panel) {
		JLabel label = new JLabel();
		label.setText("<html>" + fieldName + "<strong> : " + inputValue
				+ "</strong></html>");
		label.setFont(NORMAL_FONT);
		panel.add(label);

	}

	private JFrame drawNewFrame(String frameName) {
		final JFrame frame = new JFrame(frameName);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
		return frame;
	}

	// Finds the size of the screen
	private static void findScreenSize() {
		Toolkit toolkit = Toolkit.getDefaultToolkit();
		Dimension dim = toolkit.getScreenSize();
		ScreenHeight = dim.height;
		ScreenWidth = dim.width;
	}

	// Centres the dialogue box within the screen
	private static void centerFrame(JFrame Frame, boolean Width) {
		findScreenSize();

		if (!Width) { // if you are not justifying on the X axis
			Frame.setLocation(Frame.getLocationOnScreen().x,
					((ScreenWidth / 2) - (Frame.getWidth() / 2)));
		} else {
			Frame.setLocation(((ScreenWidth / 2) - (Frame.getWidth() / 2)),
					((ScreenHeight / 2) - (Frame.getHeight() / 2)));
		}
	}

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		/* Set the Nimbus look and feel */
		// <editor-fold defaultstate="collapsed"
		// desc=" Look and feel setting code (optional) ">
		/*
		 * If Nimbus (introduced in Java SE 6) is not available, stay with the
		 * default look and feel. For details see
		 * http://download.oracle.com/javase
		 * /tutorial/uiswing/lookandfeel/plaf.html
		 */
		try {
			UIManager.LookAndFeelInfo[] installedLookAndFeels = UIManager
					.getInstalledLookAndFeels();
			for (int idx = 0; idx < installedLookAndFeels.length; idx++)
				if ("Nimbus".equals(installedLookAndFeels[idx].getName())) {
					UIManager.setLookAndFeel(installedLookAndFeels[idx]
							.getClassName());
					break;
				}

		} catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(
					MainGuiRegistrationForm.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(
					MainGuiRegistrationForm.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(
					MainGuiRegistrationForm.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(
					MainGuiRegistrationForm.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		}
		// </editor-fold>

		/* Create and display the form */
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				mainFrame = new MainGuiRegistrationForm();
				mainFrame.setVisible(true);
				centerFrame(mainFrame, true);
			}
		});
	}

	public static int getSelectedStend() {
		return selectedStend;
	}

	public static void setSelectedStend(int selectedStend) {
		MainGuiRegistrationForm.selectedStend = selectedStend;
	}

	public boolean isIntSelected() {
		return isIntSelected;
	}

	public void setIntSelected(boolean isIntSelected) {
		this.isIntSelected = isIntSelected;
	}

	public static int getIsSetUserPermissions() {
		return isSetUserPermissions;
	}

	public static void setIsSetUserPermissions(int isSetUserPermissions) {
		MainGuiRegistrationForm.isSetUserPermissions = isSetUserPermissions;
	}

	private static int getIsSetIntPermissions() {
		return isSetIntPermissions;
	}

	private static void setIsSetIntPermissions(int isSetIntPermissions) {
		MainGuiRegistrationForm.isSetIntPermissions = isSetIntPermissions;
	}

	// Variables declaration - do not modify
	private JButton cancelButton, checkOrgDataButton, checkUserDataButton,
			clearFormButon, registerButton, okSuccessButton;
	private JLabel emailLabel, firstNameLabel, fullNameLabel, innLabel,
			kppLabel, lastNameLabel, loginLabel, middleNameLabel, ogrnLabel,
			phoneLabel, isOgrnUniqueLabel, isKppUniqueLabel, isInnUniqueLabel,
			isLoginUniqueLabel, registrationSuccessLabel, infoResultLabel,
			infoResultFullNameLabel, infoResultLoginLabel,
			infoResultPasswordLabel, integrationUserLoginLabel,
			integrationUserPasswordLabel;

	private JTextField emailTextField;
	private JFormattedTextField ogrnTextField, innTextField, kppTextField,
			fullNameTextField, phoneTextField, userLoginTextField,
			firstNameTextField, lastNameTextField, middleNameTextField,
			integrationUserPasswordTextField, integrationUserLoginTextField;

	private JPanel userDataPanel, orgDataPanel, registerResultPanel,
			stendPanel;
	private JRadioButton stendKpakRadioButton, stendIntRadioButton,
			stendTpakRadioButton;

	private static String orgId, orgFullName, orgOgrn, orgInn, orgKpp,
			orgEmail, orgAddressId, orgPhone, orgWebsite, userLogin, userId,
			userFirstName, userLastName, userMiddleName, userIntLogin,
			userIntPassword;

	// Дефолтные значения
	private static String userPassword = "11111";
	private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
			+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
	
	private static final String INT_PASSWORD_PATTERN ="((?=.*\\d{3})(?=.*[a-z])(?=.*[A-Z]).{9,20})";
	private Pattern pattern;
	private Matcher matcher;

	private static JFrame registerResultFrame;

	private static int ScreenWidth, ScreenHeight, selectedStend,
			isSetUserPermissions, isSetIntPermissions;

	private DataBaseUtils db = new DataBaseUtils();

	private static final Color OK_LABEL_COLOR = new Color(0, 0, 255);
	private static final Color ERR_LABEL_COLOR = new Color(255, 51, 51);
	private static final Font WARNING_FONT = new Font("SansSerif", Font.BOLD
			| Font.ITALIC, 12);
	private static final Color BLACK_FOREGROUNG = java.awt.Color.black;
	private static final Color WHITE_FOREGROUND = java.awt.Color.white;
	private static final Font NORMAL_FONT = new java.awt.Font("SansSerif", 0,
			12);
	private final ButtonGroup chooseStendButtonGroup = new ButtonGroup();
	private JCheckBox createIntUserCheckBox, setUserPermissionsCheckBox,
			setIntPermissionsCheckBox;
	private JPanel intSettingsPanel;
	private JPanel fstTabContainerPanel;
	private boolean isIntSelected = false;
	private MyVerifier verifier = new MyVerifier();

	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		// TODO Auto-generated method stub

	}

}
